from books import Books
from engine import connect
from session import session
def queryid(session,id): #根据编号查询数据
    rows = session.query(Books.编号,Books.书名,Books.作者,Books.出版社,Books.出版日期,Books.定价).filter_by(编号=id).all()
    print("查询的编号为"+id+"的图书信息如下：")
    #对结果进行格式输出
    print("-"*120)
    for row in rows:
        for i in range(len(row)):
            print(row[i],end=" ")
if __name__ == "__main__":
    conn = connect() #获取数据库连接
    session = session(conn) #获取session
    #查询记录
    queryid(session,input("请输入要查询的记录编号："))
    session.close()